<template>
  <div>
    <div class="infoIpt">
      <!--            <a-row>-->
      <!--                <a-col span="24">-->
      <!--                    <a-icon type="left-circle" theme="filled"  style="font-size: 30px; color: #48D3A4;"  @click="back"/>-->
      <!--                </a-col>-->
      <!--            </a-row>-->
      <br />

      <a-row :gutter="16" style="margin: 0 10px;">
        <a-col :xl="6" :lg="24" :md="24" :sm="24" :xs="24">
          <a-card style="min-height: 450px;">
            <template #title>
              <a-row>
                <a-col span="16">
                  <div style="font-size: 1.2rem; font-weight: bold; color: #189583">
                    <a-icon type="info-circle" /> &nbsp;专家信息
                  </div>
                </a-col>
                <a-col span="8">
                  <div
                    style="font-size: 1.2rem; font-weight: bold; color: #189583; cursor: pointer; display: flex; justify-content: space-around; align-items: center;">
                    <a-icon type="like" @click="changeLike" v-if="!likeStatus" title="点赞"/>
                    <a-icon type="like" theme="filled" @click="changeLike" v-else  title="取消点赞"/>
                    <a-popover trigger="click">
                      <template slot="content">
                        <template v-for="(item, index)  in likeData">
                          <a-row style="width: 280px; font-size: 13px; line-height: 30px; font-weight: bold; ">
                            <a-col span="10" style="text-align: right;">{{ item.likeItem }}：</a-col>
                            <a-col span="12">
                              <a-rate :allowClear="false" v-model="item.likeCount"
                                      @change="changeEvaluate(index, item.likeCount)" />
                            </a-col>
                          </a-row>
                        </template>
                      </template>
                      <a-icon type="form" title="评价"/>
                    </a-popover>
                    <a-icon type="file-search" @click="showDataAnalysis"  title="数据分析报告"/> &nbsp;
                    <a-icon type="fund" @click="showAbilityAnalysis"  title="能力演化分析"/> &nbsp;
                  </div>
                </a-col>
              </a-row>
            </template>
            <div>
              <a-row :gutter="16" type="flex" justify="space-around">
                <a-col span="8" style="display: flex; justify-content: center;">
                  <a-avatar shape="square" :size="80"
                            :src="talentInfo.talentPhoto != null ? talentInfo.talentPhoto : talentInfo.talentGender != null ? talentInfo.talentGender== '男' ? manPhoto : womanPhoto : unknownPhoto" />
                </a-col>
                <a-col span="16">
                  <div class="t-title">{{ talentInfo.talentRealName }}</div>
                  <div class="t-company" :title="talentInfo.talentCompany">{{ talentInfo.talentCompany }}</div>
                </a-col>
              </a-row>
              <br />
              <a-row v-if="talentInfo.talentPartPhoneNumber != ''">
                <a-col span="24">
                  <div class="title">
                    电话:
                    <span
                      style="font-weight: bold; padding-left: 20px;">{{
                        talentInfo.talentPartPhoneNumber == null ? '待补充' : talentInfo.talentPartPhoneNumber
                      }}</span>
                  </div>
                </a-col>
              </a-row>
              <br />
              <a-row v-if="talentInfo.talentIntro != ''">
                <a-col span="24">
                  <div class="title">
                    简介: <span v-if="talentInfo.talentIntro == null"
                                style="font-weight: bold; padding-left: 20px;">待补充</span>
                  </div>
                  <div class="title" v-if="talentInfo.talentIntro != null ">
                    <div
                      style="font-weight: bold; line-height: 25px; text-align: justify; text-indent: 2em">
                      {{ talentInfo.talentIntro }}
                    </div>
                  </div>
                </a-col>
              </a-row>
              <br />
              <a-row>
                <a-col span="24">
                  <div class="title">
                    研究领域:<br />
                    <div v-if="talentFields != null">
                      <template v-for="(tag,index) in talentFields">
                        <a-tag :title="tag" v-if="index<10"
                               style="line-height: 20px; margin-top: 5px; background: #fff; color: #19927F; border-style: solid; border-color: #19927F; float: left;">
                          {{ tag }}
                        </a-tag>
                      </template>
                    </div>
                    <div v-else style="font-weight: bold; padding: 20px;">待补充</div>
                  </div>
                </a-col>
              </a-row>
            </div>
          </a-card>
          <div
            style="width: 100%; background-color: #19927F; text-align: center; margin: 20px 0; line-height: 30px; color: #fff; cursor: pointer;"
            @click="toShareResources">
            <a-badge :offset="[20, -5]" :count="talentFileNum">
              <span style="width: 100px;">资源共享</span>
            </a-badge>
          </div>
          <a-card style="min-height: 490px;">
            <template #title>
              <div style="font-size: 1.2rem; font-weight: bold; color: #189583">
                <a-icon type="usergroup-delete" style=" font-weight: bold" size="25" /> &nbsp;专家相关性分析
              </div>
            </template>
            <div v-show="talentRelatedYgDataList && talentRelatedYgDataList.length>0">
              <div ref="groupYgCharts" style=" height: 400px; width: 100%;"></div>
            </div>
            <div v-show="talentRelatedYgDataList== null">
              <div class="blank-content">
                <a-empty />
              </div>
            </div>
          </a-card>
        </a-col>
        <a-col :xl="10" :lg="24" :md="24" :sm="24" :xs="24">
          <div style="height: 400px; border: 1px solid #e8e8e8;">
            <div class="divTitle">
              <a-icon type="pie-chart" style="font-weight: bold" size="25" /> &nbsp;专家成果分析
            </div>
            <a-tabs type="card" @change="handleTabChange">
              <a-tab-pane key="cy" tab="成果词云">
                <div v-if="talentFruitWordCloudDataList && talentFruitWordCloudDataList.length>0">
                  <!--                                    <word-cloud-index :data="wordData" :width="450" v-if="isHaveWordData"></word-cloud-index>-->
                  <tag-cloud :data="wordData"></tag-cloud>
                </div>
                <div v-else>
                  <div class="blank-content">
                    <a-empty />
                  </div>
                </div>
              </a-tab-pane>
              <a-tab-pane key="rrff" tab="研究领域成果分布">
                <div
                  v-show="talentRelatedResearchFieldFruitDataList && talentRelatedResearchFieldFruitDataList.length>0">
                  <div ref="researchFieldChart" style="height: 400px; width: 100%;"></div>
                </div>
                <div v-show="talentRelatedResearchFieldFruitDataList== null">
                  <div class="blank-content">
                    <a-empty />
                  </div>
                </div>
              </a-tab-pane>
            </a-tabs>
          </div>
          <br />
          <a-card style="height: 600px;">
            <template #title>
              <div style="font-size: 1.2rem; font-weight: bold; color: #189583">
                <a-icon type="file" style=" font-weight: bold" size="25" /> &nbsp;个人成果
              </div>
            </template>
            <div style="height: 480px; overflow-y: auto; overflow-x: hidden;">
              <a-row>
                <a-col span="24">
                  <div class="demo-spin-div" v-if="!isHaveData">
                    <a-spin tips="">
                      <div class="spin-content">
                        成果数据加载中。。。
                      </div>
                    </a-spin>
                  </div>
                  <div v-if="isHaveData">
                    <div>
                      <a-radio-group v-model="selectedFruitType" button-style="solid" @change="changeType">
                        <a-radio-button value="">
                          全部
                        </a-radio-button>
                        <a-radio-button value="6">
                          学术论文
                        </a-radio-button>
                        <a-radio-button value="13">
                          期刊成果
                        </a-radio-button>
                        <a-radio-button value="20">
                          国际会议
                        </a-radio-button>
                        <a-radio-button value="21">
                          国际论坛
                        </a-radio-button>
                      </a-radio-group>
                    </div>
                    <div v-if="productions.dataList.length > 0" style="padding-left: 10px;">
                      <div v-for="item in productions.dataList" :key="item.id">
                        <a-divider />
                        <a-row>
                          <a-col :xl="20" :lg="20" :md="24" :sm="24" :xs="24">
                            <div class="ft" @click="showFruitInfo(item)">
                              {{ item.fruitName }}
                            </div>
                          </a-col>
                          <a-col :xl="4" :lg="4" :md="24" :sm="24" :xs="24" style="text-align: right;">
                            <a-tag color="#189583"
                                   style="font-size: 15px;border-radius: 10px;padding: 0 10px;text-align: center;}">
                              <span>{{ getFruitTypeName(item.fruitType) }}</span>
                            </a-tag>
                          </a-col>
                        </a-row>
                        <a-row style="margin-top: 5px;">
                          <a-col span="24">
                            <template v-if="item.fruitKeywords">
                              <template v-for="(tag,index) in item.fruitKeywords.split(',')">
                                <a-tag v-if="index < 3" :key="tag"
                                       style="line-height: 20px; border-style: dashed; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;  max-width: 200px; float: left;">
                                  {{ tag }}
                                </a-tag>
                              </template>
                            </template>
                          </a-col>
                        </a-row>
                        <a-row style="margin-top: 5px;">
                          <a-col :xl="18" :lg="18" :md="24" :sm="24" :xs="24">
                            <div style="font-size: 15px; ">
                              <div v-if="item.tagList">
                                                            <span v-for="(tagGroup, index) in item.tagList"
                                                                  :key="index">
                                                              <span
                                                                v-if="tagGroup.tagTypeName === 'fruit_author_names'">
                                                                <span v-for="(author, idx) in tagGroup.tagNameList"
                                                                      :key="idx">
                                                                  {{ author.tagName }}
                                                                  <span
                                                                    v-if="idx < tagGroup.tagNameList.length - 1">, </span>
                                                                </span>
                                                              </span>
                                                            </span>
                              </div>
                            </div>
                            <!--                                                        <div style="display: inline-block; font-size: 15px; padding-left: 30px;">{{item.orgName}}</div>-->
                          </a-col>
                          <a-col :xl="6" :lg="6" :md="24" :sm="24" :xs="24" style="text-align: right; ">
                            <div style="font-size: 15px">
                              {{ item.fruitPubTime }}
                            </div>
                          </a-col>
                        </a-row>
                        <!--                                                <a-row style="margin-top: 5px;">-->
                        <!--                                                    <a-col span="20">-->
                        <!--                                                        <div style="color: #189583; padding-right: 10px; font-size: 13px; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; ">{{item.field}}</div>-->
                        <!--                                                    </a-col>-->
                        <!--                                                    <a-col span="4" style="text-align: right; padding-right: 20px;">-->
                        <!--                                                        <div style="font-size: 15px">{{item.pubTime.substring(0,10)}}</div>-->
                        <!--                                                    </a-col>-->
                        <!--                                                </a-row>-->
                      </div>
                    </div>
                    <div v-else>
                      <div class="blank-content">
                        <a-empty />
                      </div>
                    </div>
                  </div>
                </a-col>
              </a-row>
            </div>
            <br />
            <a-row>
              <a-col span="24">
                <div class="pag">
                  <a-pagination :current="currentPage"
                                :total="parseInt(productions.total)"
                                :show-total="total => `共 ${total} 条`"
                                @change="onChangePage" />
                </div>
              </a-col>
            </a-row>
          </a-card>
        </a-col>
        <a-col :xl="8" :lg="24" :md="24" :sm="24" :xs="24">
          <div style="height: 400px; border: 1px solid #e8e8e8;">
            <div class="divTitle">
              <a-icon type="bar-chart" style="font-weight: bold" size="25" /> &nbsp;专家合作情况
            </div>
            <a-tabs type="card" @change="handleTabChange">
              <a-tab-pane key="related" tab="合作学者">
                <div v-show="talentRelatedTalentDataList && talentRelatedTalentDataList.length>0">
                  <div ref="groupTalentCharts" style="height: 350px; width: 100%;"></div>
                </div>
                <div v-show="talentRelatedTalentDataList== null">
                  <div class="blank-content">
                    <a-empty />
                  </div>
                </div>
              </a-tab-pane>
              <a-tab-pane key="rank" tab="合作排名">
                <div v-show="talentRelatedTalentDataList && talentRelatedTalentDataList.length>0">
                  <div ref="groupRankCharts" style=" height: 350px; width: 100%;"></div>
                </div>
                <div v-show="talentRelatedTalentDataList== null">
                  <div class="blank-content">
                    <a-empty />
                  </div>
                </div>
              </a-tab-pane>
            </a-tabs>
          </div>
          <br />
          <a-card style="height: 600px;">
            <template #title>
              <div style="font-size: 1.2rem; font-weight: bold; color: #189583">
                <a-icon type="line-chart" style=" font-weight: bold" size="25" /> &nbsp;专家研究趋势
              </div>
            </template>
            <div v-show="talentResearchTrendDataList && talentResearchTrendDataList.length>0">
              <div ref="researchCharts" style="height: 500px; width: 100%;"></div>
            </div>
            <div v-show="talentResearchTrendDataList== null">
              <div class="blank-content">
                <a-empty />
              </div>
            </div>
          </a-card>
        </a-col>
      </a-row>
    </div>
    <fruit-info ref="fruitInfo"></fruit-info>

    <a-modal :width="1000" v-model="uploadModal" title="共享资源信息" :mask-closable="false" :footer="null">
      <a-upload
        name="file"
        :showUploadList="false"
        :beforeUpload="fileBeforeUpload"
        :action="$uploadUrl"
        :data="uploadData"
        @change="uploadSuccess"
      >
        <a-button type="primary" icon="plus"> 上传资源</a-button>
      </a-upload>
      <br />

      <!-- 列表展示 -->
      <a-table :columns="columns" :dataSource="talentFileData.dataList" :loading="isHaveFileData"
               :rowKey="record => record.id" :pagination="false">
        <template slot="action" slot-scope="text, record">
          <a-popconfirm
            title="是否确认删除此条数据?"
            ok-text="是"
            cancel-text="否"
            @confirm="deleteFile(record)"
            v-if="record.uploadUserId == uploadData.uploadUserId"
          >
            <a-button type="danger">删除</a-button>
          </a-popconfirm> &nbsp; &nbsp;
          <a-button type="primary" @click="downloadFileData(record)">下载</a-button>
        </template>
      </a-table>
      <br />
      <!-- 分页器 -->
      <a-pagination :show-total="total => `共${total}条`" :total="talentFileData.total" :current="pagination.current"
                    :pageSize="pagination.pageSize" @change="onChangeTalentFilePage" />
    </a-modal>


    <a-modal :width="1000" v-model="dataAnalysisModel" title="数据分析报告" :mask-closable="false" :footer="null">
      <div style="color: #1b967b; font-size: 16px; padding: 15px;">
        该专家是新型电力系统研究方面的专家，且邀请专家的总体次数为{{ dataAnalysisObj.totalNum }}次，
        邀请到场率为{{ dataAnalysisObj.totalNum > 1 ? '100%' : '0%' }}；专家参与方式主要有两种，其中{{ dataAnalysisObj.totalOffLineNum }}次该专家选择线下参与，亲自到场与团队成员面对面交流互动；
        另有{{ dataAnalysisObj.totalOnLineNum }}次该专家通过视频会议、电话会议等方式线上参与。
        在费用支付方面，该专家属于高级专家，其平均费用支付为{{ dataAnalysisObj.averageAmount }}元/次。
      </div>
      <!-- 列表展示 -->
      <a-table :columns="dataAnalysisColumns" :dataSource="dataAnalysisList" />
    </a-modal>


    <a-modal :width="900" v-model="abilityAnalysisModel" title="能力演化分析" :mask-closable="false" :footer="null">
      <a-row :gutter="16">
        <a-col :span="24">
          <a-card title="时间范围">
            <div style="display: flex; align-items: center;">
              <span style="margin-right: 8px;">{{yearStartRange[0]}}年</span>
              <a-slider
                v-model="yearRange"
                :min="yearStartRange[0]"
                :max="yearStartRange[1]"
                range
                style="flex: 1;"
                @change="getAbilityAnalysisData"
              />
              <span style="margin-left: 8px;">{{yearStartRange[1]}}年</span>
            </div>
            <div style="margin-top: 8px;">
              <span>开始年份 <b>{{ yearRange[0] }}</b></span>
              <span style="margin-left: 24px;">结束年份 <b>{{ yearRange[1] }}</b></span>
            </div>
          </a-card>
        </a-col>
        <a-col :span="24" style="margin-top: 24px;">
          <p style="font-size: 16px; font-weight: bold; margin-bottom: 15px;">研究关键词演化时间线</p>
          <a-timeline>
            <a-timeline-item v-for="item in abilityAnalysisList" :key="item.id">
              <a-row>
                <a-col span="4">
                  <div style="width: 80px; font-weight: bold; font-size: 16px; color: #1890ff; text-align: right; margin-right: 16px;">
                    {{ item.year }}年
                    <div style="font-size: 12px; color: #8c8c8c;">{{ item.month }}月</div>
                  </div>
                </a-col>
                <a-col span="20">
                  <div style="flex-grow: 1;">
                    <template v-for="(citm, index) in item.keywords">
                      <div class="timeline-keyword" v-if="index < 5">
                        <span style="font-weight: bold;">{{ citm.keyword }}</span>
                        ({{ citm.count }}次)
                      </div>
                    </template>
                  </div>
                </a-col>
              </a-row>
            </a-timeline-item>
          </a-timeline>
        </a-col>
      </a-row>


    </a-modal>

    <div id="components-back-top-demo-custom">
      <a-back-top>
        <div class="ant-back-top-inner">
          <a-icon type="up-circle" theme="filled" />
        </div>
      </a-back-top>
    </div>
  </div>
</template>

<script>

import * as echarts from 'echarts'
import Setting from '@/setting'
import photo from '../common/photo.png'
import womanPhoto from '../common/womanPhoto.png'
import manPhoto from '../common/manPhoto.png'
import unknownPhoto from '../common/unknownPhoto.png'
import { commonPostAction, downloadData, downloadFile, postAction } from '@/api/esManage'
import { getFruitTypeName } from '@/utils/tools'
import fruitInfo from '../FruitInfo.vue'
import wordCloudIndex from '../common/wordCloud/wordcloudIndex.vue'
import tagCloud from '../common/tagCloud/tagCloud.vue'

function getRandomArrayElements(arr, count) {
  let shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index
  while (i-- > min) {
    index = Math.floor((i + 1) * Math.random())
    temp = shuffled[index]
    shuffled[index] = shuffled[i]
    shuffled[i] = temp
  }
  return shuffled.slice(min)
}

export default {
  name: 'TalentInfo',
  components: {
    fruitInfo,
    wordCloudIndex,
    tagCloud
  },
  data() {
    return {
      photo: photo,
      womanPhoto: womanPhoto,
      manPhoto: manPhoto,
      unknownPhoto: unknownPhoto,
      loading: false,
      searchTalentFruitObj: {
        current: 1,
        pageNo: 1,
        pageSize: 10,
        sortField: 'fruitPubTime'
      },
      selectedAuthorId: '',
      selectedAuthorName: '',
      gwFieldNames: [],
      researchTags: [],
      talentInfo: {},
      talentFields: [],
      talentFileNum: 0,
      currentYear: '',
      yearList: [],
      selectedFruitType: '',
      currentPage: 1,
      searchObj: {
        pageNo: 1,
        pageSize: 10
      },
      fruitTypeList: [
        { 'name': '学术论文', 'value': 6 },
        { 'name': '研究报告', 'value': 3 },
        { 'name': '图书出版', 'value': 7 },
        { 'name': '活动成果', 'value': 4 },
        { 'name': '媒体成果', 'value': 5 },
        { 'name': '荣誉信息', 'value': 8 },
        { 'name': '专利成果', 'value': 11 },
        { 'name': '软著成果', 'value': 12 }
      ],
      isHaveData: true,
      productions: {
        dataList: []
      },
      isHaveWordData: false,
      wordData: [],
      talentRecommendData: [],
      talentResearchTrendDataList: [],
      talentRelatedResearchFieldFruitDataList: [],
      talentFruitWordCloudDataList: [],
      talentRelatedYgDataList: [],
      talentRelatedTalentDataList: [],

      uploadModal: false,
      searchTalentFileObj: {
        relationId: '',
        pageNo: 1,
        pageSize: 10
      },
      isHaveFileData: true,
      talentFileData: {
        total: 0,
        dataList: []
      },
      currentFilePage: 1,
      talentFileList: [],
      uploadData: {
        relationId: '',
        uploadUserId: ''
      },
      columns: [
        {
          title: '序号',
          dataIndex: 'key',
          align: 'center',
          customRender: (text, record, index) => `${index + 1}`//此处为重点
        },
        {
          title: '资源名称',
          dataIndex: 'name'
        },
        {
          title: '上传人',
          dataIndex: 'uploadUserName'
        },
        {
          title: '上传时间',
          dataIndex: 'createTime',
          customRender: (text, record) => `${record.createTime == null || record.createTime == '' ? '' : record.createTime.substring(0, 10)}`//此处为重点
        },
        {
          title: '操作',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' }
        }
      ],
      pagination: {
        current: 1,
        pageSize: 10
      },
      searchTalentLikeObj: {
        talentId: '',
        userId: 1
      },
      likeStatus: false,
      likeData: [],
      likeObj: '',
      dataAnalysisModel: false,
      dataAnalysisList: [],
      dataAnalysisColumns: [
        {
          title: '合作专家类型',
          dataIndex: 'field'
        },
        {
          title: '总邀请次数(次)',
          dataIndex: 'totalNum'
        },
        {
          title: '邀请成功率(%)',
          dataIndex: 'successRate'
        },
        {
          title: '线下参与次数(次)',
          dataIndex: 'totalOffLineNum'
        },
        {
          title: '线上参与次数(次)',
          dataIndex: 'totalOnLineNum'
        }
      ],
      dataAnalysisObj: {},
      abilityAnalysisModel: false,
      abilityAnalysisList: [],
      yearStartRange: [2010, new Date().getFullYear()],
      yearRange: [new Date().getFullYear()-2 , new Date().getFullYear()]
    }
  },
  computed: {},
  mounted() {
  },
  created() {
    this.showInfo(this.$route.query.t, this.$route.query.c)
  },
  methods: {
    getFruitTypeName,
    back() {
      this.$emit('toShowPhotoPage', false)
    },
    getYear() {
      this.yearList = []
      //取最近5年
      let currentYear = new Date().getFullYear()
      this.currentYear = currentYear
      for (let n in 10) {
        this.yearList.push({ 'name': currentYear - n, 'value': currentYear - n })
      }
    },
    showInfo(authorId, authorName) {
      this.selectedAuthorId = authorId
      this.selectedAuthorName = authorName
      this.$nextTick(function() {
        // this.getYear();
        this.getTalentInfoData()
      })

      window.scrollTo({
        top: 0,
        behavior: 'smooth' // 使用平滑滚动
      })
    },
    getTalentFieldTagData() {
      // let url = "/fruit/getTalentFieldTagData";
      //
      // let obj = {orgUserId : this.selectedAuthorId};
      // let that = this;
      // postAction(url, obj).then(res => {
      //     if (res.data.success) {
      //         let randomTags = getRandomArrayElements(res.data.result, 2);
      //         that.researchTags = res.data.result;
      //         that.getRecommendTalent(randomTags.map(item=>{return item.name;}));
      //     }
      // }).catch(err => {
      //     console.log(err)
      // })
      this.gwFieldNames = this.talentInfo.gwFieldNames ? this.talentInfo.gwFieldNames.split(',') : null
      let resultArr = this.talentInfo.s ? this.talentInfo.s.split(',') : null
      if (resultArr) {
        let randomTags = getRandomArrayElements(resultArr, 2)
        this.researchTags = getRandomArrayElements(resultArr, 8)
        this.getRecommendTalent(randomTags.map(item => {
          return item
        }))
      }
    },
    getTalentInfoData() {
      let url = '/talents/getTalentInfo'
      postAction(url, { authorId: this.selectedAuthorId }).then(res => {
        if (res.data.success) {
          this.talentInfo = res.data.result
          this.talentFields = this.talentInfo.talentGwFields ? this.talentInfo.talentGwFields.split(',') : null
          // this.getTalentFieldTagData();
          this.talentResearchTrendDataList = JSON.parse(res.data.result.talentResearchTrendDataList)
          if (this.talentResearchTrendDataList != null) {
            this.getResearchChartsData(this.talentResearchTrendDataList)
          }
          // this.talentRelatedResearchFieldFruitDataList = JSON.parse(res.data.result.talentRelatedResearchFieldFruitDataList);
          // if(this.talentRelatedResearchFieldFruitDataList != null){
          //     this.getResearchFieldFruitCharts(this.talentRelatedResearchFieldFruitDataList);
          // }
          this.talentFruitWordCloudDataList = JSON.parse(res.data.result.talentFruitWordCloudDataList)
          if (this.talentFruitWordCloudDataList != null) {
            this.getFruitWordCloudData(this.talentFruitWordCloudDataList)
          }
          this.talentRelatedYgDataList = JSON.parse(res.data.result.talentRelatedYgDataList)
          if (this.talentRelatedYgDataList != null) {
            this.getRelatedYgData(this.talentRelatedYgDataList)
          }
          this.talentRelatedTalentDataList = JSON.parse(res.data.result.talentRelatedTalentDataList)
          // if(this.talentRelatedTalentDataList != null){
          //     this.getRelatedTalentData(this.talentRelatedTalentDataList);
          // }
          this.handleTabChange('cy')
          this.handleTabChange('related')
          this.getLikeData()
        }
      }).catch(err => {
        console.log(err)
      })
      this.getFruitData('')
      this.getTalentFileNum()
    },
    getFruitData(fruitType) {
      let fruitUrl = '/talents/getPageTalentFruitList'
      this.searchTalentFruitObj.authorId = this.selectedAuthorId
      // this.searchTalentFruitObj.authorName = this.selectedAuthorName;
      this.searchTalentFruitObj.searchType = 1
      this.searchTalentFruitObj.fruitType = fruitType
      this.isHaveData = false
      postAction(fruitUrl, this.searchTalentFruitObj).then(res => {
        if (res.data.success) {
          this.productions.total = res.data.result.total
          this.productions.dataList = res.data.result.records
          this.isHaveData = true
        }
      }).catch(err => {
        console.log(err)
      })
    },
    changeType(e) {
      this.selectedFruitType = e.target.value
      this.getFruitData(e.target.value)
    },
    onChangePage(value) {
      this.searchTalentFruitObj.pageNo = value
      this.currentPage = value
      this.getFruitData()

      window.scrollTo({
        top: 1500,
        behavior: 'smooth' // 使用平滑滚动
      })
    },
    getTalentFileNum() {
      let url = '/file/getTalentFileNum'
      commonPostAction(url, { relationId: this.selectedAuthorId }).then(res => {
        if (res.data.success) {
          this.talentFileNum = res.data.result
        }
      }).catch(err => {
        console.log(err)
      })
    },
    getResearchChartsData(data) {
      let legendData = []
      let seriesData = []
      for (let n in data) {
        let result = []
        result[0] = data[n].yearNum
        result[1] = data[n].count
        result[2] = data[n].name
        legendData.push(data[n].name)
      }
      this.buildResearchCharts(Array.from(new Set(legendData)), data)
    },
    buildResearchCharts(legendData, seriesData) {
      let researchCharts = echarts.init(this.$refs.researchCharts)
      this.buildResearchCategoryCharts(researchCharts, legendData, seriesData)
    },
    buildResearchCategoryCharts(researchCharts, legendData, seriesData) {

      var groupedData = {}
      var allUniqueYears = new Set() // 用于存储所有独特的年份

      // 遍历输入数据，按 name 进行分组，并收集独特年份
      seriesData.forEach(function(item) {
        if (!groupedData[item.name]) {
          groupedData[item.name] = {}
        }

        // 使用 yearNum 作为属性，存储每个 yearNum 对应的 count 值
        groupedData[item.name][item.yearNum] = item.count
        allUniqueYears.add(item.yearNum) // 添加年份到独特年份集合中
      })

      // 将所有独特年份转换为一个排序后的数组
      var sortedUniqueYears = Array.from(allUniqueYears).sort((a, b) => a - b)

      var newDataArray = []

      // 遍历每个 name，构建新的数组结构
      for (var name in groupedData) {
        var newDataItem = {
          name: name, // 使用 name 字段的值作为 name
          type: 'line',
          // smooth: true,
          data: sortedUniqueYears.map(year => groupedData[name][year] || 0) // 使用映射来填充数据
        }

        // 将 newDataItem 添加到新的数组结构中
        newDataArray.push(newDataItem)
      }

      // 生成不同的颜色
      function generateUniqueColors(count) {
        var colors = []
        for (var i = 0; i < count; i++) {
          var hue = (360 / count) * i
          var lightness = (i % 2 === 0 ? 30 : 70) / 100 // 转换为0-1范围
          var color = `hsl(${hue}, 100%, ${lightness})`
          colors.push(color)
        }
        return colors
      }

      // 定义颜色数量（应与系列数据的数量相匹配，或根据需要调整）
      var colorCount = Object.keys(groupedData).length // 或使用您想要的颜色数量
      var customColors = generateUniqueColors(28)

      // 假设 researchCharts 是已经初始化的图表实例
      researchCharts.setOption({
        // color: customColors,
        legend: {
          top: '10px',
          data: Object.keys(groupedData) // 使用分组数据的键作为图例数据
        },
        grid: {
          top: colorCount > 6 ? '200px' : '100px',
          bottom: '50px'
        },
        tooltip: {
          trigger: 'axis',
          extraCssText: 'z-index: 7',
          backgroundColor: '#FFFFFF',
          textStyle: {
            color: '#3c3520'
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: sortedUniqueYears // 使用排序后的独特年份作为x轴数据
        },
        yAxis: {
          type: 'value',
          minInterval: 1
        },
        series: newDataArray
      }, true)

      setTimeout(function() {
        researchCharts.resize()
      }, 10)
    },
    getResearchFieldFruitCharts(data) {
      // this.buildResearchChart(resultData);
      this.buildResearchPieChart(data)
    },
    buildResearchChart(resultData) {
      let rfCharts = echarts.init(this.$refs.researchFieldChart)
      let linksArr = []
      let nodesArr = []
      let max = 0
      if (resultData != null && resultData.length > 0) {
        resultData.forEach(v => {
          linksArr.push({
            source: v.start_node,
            target: v.end_node,
            sourceName: v.start_node_name,
            targetName: v.end_node_name,
            value: v.cross_times
          })
          if (nodesArr.length === 0) {
            nodesArr = [
              {
                id: v.start_node,
                name: v.start_node_name,
                value: v.cross_times
              },
              {
                id: v.end_node,
                name: v.end_node_name,
                value: v.cross_times
              }
            ]
            max = Math.max(max, v.cross_times)
          } else {
            const sourceItem = nodesArr.findIndex(j => j.id === v.start_node)
            if (sourceItem < 0) { // 找不到相同的起始路段的id
              nodesArr.push({
                id: v.start_node,
                name: v.start_node_name,
                value: v.cross_times
              })
              max = Math.max(max, v.cross_times)
            } else { // 累加value的值
              nodesArr[sourceItem].value += v.cross_times
              max = Math.max(max, nodesArr[sourceItem].value)
            }
            const targetItem = nodesArr.findIndex(j => j.id === v.end_node)
            if (targetItem < 0) { // 找不到相同的结束路段的id
              nodesArr.push({
                id: v.end_node,
                name: v.end_node_name,
                value: v.cross_times
              })
              max = Math.max(max, v.cross_times)
            } else { // 累加value的值
              nodesArr[targetItem].value += v.cross_times
              max = Math.max(max, nodesArr[targetItem].value)
            }
          }
        })

        nodesArr.forEach(v => { // 按照最大值平均分16等份，并设置nodes的symbolSize
          v.symbolSize = this.averageSize(v.value, max)
          v.category = v.name
          v.label = {
            normal: {
              show: true
            }
          }
        })

        let sliNumer = 0
        try {
          sliNumer = Math.ceil(nodesArr.length / 4)
        } catch (error) {
          sliNumer = 0
        }
        if (sliNumer > 0) { // 因和弦图设置为环形状态时，默认会从90度位置顺时针旋转显示，所以把最初始的四分之一数据，添加到最后，即可实现从0度开始顺时针旋转的效果，可根据业务自定义更改数据的位置
          let nodeCopyArr = nodesArr
          nodesArr = (nodeCopyArr.slice(sliNumer, nodeCopyArr.length)).concat(nodeCopyArr.slice(0, sliNumer))
        }
      }
      let categoriesArr = nodesArr.length > 0 ? nodesArr.map(v => {
        return { name: v.name }
      }) : [] // 筛选出所有路段的名称
      rfCharts.setOption(
        {
          // color: ['#ff0000', '#f00000'], // 可自定义多种颜色
          tooltip: {},
          animationDurationUpdate: 1500,
          animationEasingUpdate: 'quinticInOut',
          legend: [
            {
              data: nodesArr.map(function(a) {
                return a.name
              })
            }
          ],
          series: [
            {
              type: 'graph',
              layout: 'circular',
              top: '100px',
              width: '50%',
              circular: {
                rotateLabel: true
              },
              data: nodesArr, // 所有路段的数据
              links: linksArr, // 路段连接的数据
              categories: categoriesArr, // 所有路段的名称数据
              roam: true,
              label: {
                position: 'right',
                formatter: '{b}'
              },
              lineStyle: {
                color: 'source',
                curveness: 0.3
              }
            }
          ]
        }
      )
      setTimeout(function() {
        rfCharts.resize()
      }, 10)
    },
    buildResearchPieChart(resultData) {
      let rfCharts = echarts.init(this.$refs.researchFieldChart)
      let serialData = []
      if (resultData != null && resultData.length > 0) {
        resultData.forEach(v => {
          serialData.push({ 'name': v.name, 'value': v.count })
        })
      }
      rfCharts.setOption({
        tooltip: {
          trigger: 'item'
        },
        series: [
          {
            type: 'pie',
            radius: '50%',
            center: ['50%', '40%'],
            itemStyle: {
              borderRadius: 8
            },
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            },
            label: {
              show: true,
              formatter: function(params) {
                // return params.name + " （" + params.value + "）";
                return params.name
              }
            },
            data: serialData
          }
        ]
      }, true)

      setTimeout(function() {
        rfCharts.resize()
      }, 10)
    },
    averageSize(res, max, commSize = 16) { // 平均分为16等份，等份可自定义
      const step = max / commSize
      const level = Math.ceil(res / step)
      return level * 2 + 6
    },
    // buildResearchFieldCharts(graph){
    //   let rfCharts = echarts.init(this.$refs.researchFieldChart);
    //   graph.nodes.forEach(function (node) {
    //     node.label = {
    //       show: node.symbolSize > 30
    //     };
    //   });
    //   rfCharts.setOption({
    //     title: {
    //       text: 'Les Miserables',
    //       subtext: 'Circular layout',
    //       top: 'bottom',
    //       left: 'right'
    //     },
    //     tooltip: {},
    //     legend: [
    //       {
    //         data: graph.categories.map(function (a) {
    //           return a.name;
    //         })
    //       }
    //     ],
    //     animationDurationUpdate: 1500,
    //     animationEasingUpdate: 'quinticInOut',
    //     series: [
    //       {
    //         name: 'Les Miserables',
    //         type: 'graph',
    //         layout: 'circular',
    //         circular: {
    //           rotateLabel: true
    //         },
    //         data: graph.nodes,
    //         links: graph.links,
    //         categories: graph.categories,
    //         roam: true,
    //         label: {
    //           position: 'right',
    //           formatter: '{b}'
    //         },
    //         lineStyle: {
    //           color: 'source',
    //           curveness: 0.3
    //         }
    //       }
    //     ]
    //   })
    //
    //   setTimeout(function () {
    //     rfCharts.resize();
    //   }, 10)
    // },
    getFruitWordCloudData(data) {
      this.isHaveWordData = true
      this.wordData = data
    },
    buildFruitWordCloudLine(fruitData) {
      let fruitChart = echarts.init(this.$refs.fruitLineChart)
      let legendData = ['学术论文', '研究报告', '图书出版', '活动成果', '媒体成果', '荣誉信息', '专利成果', '软著成果']
      let lineXsData = []
      let lwSeriesData = [0, 0, 0, 0, 0]
      let bgSeriesData = [0, 0, 0, 0, 0]
      let tsSeriesData = [0, 0, 0, 0, 0]
      let hdSeriesData = [0, 0, 0, 0, 0]
      let mtSeriesData = [0, 0, 0, 0, 0]
      let rySeriesData = [0, 0, 0, 0, 0]
      let zlSeriesData = [0, 0, 0, 0, 0]
      let rzSeriesData = [0, 0, 0, 0, 0]
      //补齐近五年的值
      for (let i = 4; i >= 0; i--) {
        let yearName = (this.currentYear - i) + ''
        lineXsData.push(yearName)
        for (let n in fruitData) {
          if (parseInt(fruitData[n].yearNum) == yearName) {
            if (fruitData[n].name == 6) {
              lwSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 3) {
              bgSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 7) {
              tsSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 4) {
              hdSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 5) {
              mtSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 8) {
              rySeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 11) {
              zlSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 10) {
              rzSeriesData[i] = fruitData[n].count
            }
          }
        }
      }
      fruitChart.setOption({
        legend: {
          bottom: '1px',
          data: legendData
        },
        grid: {
          top: '50px',
          bottom: '150px'
        },
        tooltip: {
          alwaysShowContent: true,
          trigger: 'axis',
          extraCssText: 'z-index: 7',
          backgroundColor: '#FFFFFF',
          textStyle: {
            color: '#3c3520'
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: lineXsData
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '学术论文',
            type: 'line',
            stack: 'Total',
            data: lwSeriesData
          },
          {
            name: '研究报告',
            type: 'line',
            data: bgSeriesData
          },
          {
            name: '图书出版',
            type: 'line',
            data: tsSeriesData
          },
          {
            name: '活动成果',
            type: 'line',
            data: hdSeriesData
          },
          {
            name: '媒体成果',
            type: 'line',
            data: mtSeriesData
          },
          {
            name: '荣誉信息',
            type: 'line',
            data: rySeriesData
          },
          {
            name: '专利成果',
            type: 'line',
            data: zlSeriesData
          },
          {
            name: '软著成果',
            type: 'line',
            data: rzSeriesData
          }
        ]
      }, true)
      setTimeout(function() {
        fruitChart.resize()
      }, 10)
    },
    buildFruitWordCloudChard(fruitData) {
      let fruitChart = echarts.init(this.$refs.fruitLineChart)
      let legendData = ['学术论文', '研究报告', '图书出版', '活动成果', '媒体成果', '荣誉信息', '专利成果', '软著成果']
      let lineXsData = []
      let lwSeriesData = [0, 0, 0, 0, 0]
      let bgSeriesData = [0, 0, 0, 0, 0]
      let tsSeriesData = [0, 0, 0, 0, 0]
      let hdSeriesData = [0, 0, 0, 0, 0]
      let mtSeriesData = [0, 0, 0, 0, 0]
      let rySeriesData = [0, 0, 0, 0, 0]
      let zlSeriesData = [0, 0, 0, 0, 0]
      let rzSeriesData = [0, 0, 0, 0, 0]
      //补齐近五年的值
      for (let i = 4; i >= 0; i--) {
        let yearName = (this.currentYear - i) + ''
        lineXsData.push(yearName)
        for (let n in fruitData) {
          if (parseInt(fruitData[n].yearNum) == yearName) {
            if (fruitData[n].name == 6) {
              lwSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 3) {
              bgSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 7) {
              tsSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 4) {
              hdSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 5) {
              mtSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 8) {
              rySeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 11) {
              zlSeriesData[i] = fruitData[n].count
            } else if (fruitData[n].name == 10) {
              rzSeriesData[i] = fruitData[n].count
            }
          }
        }
      }
      fruitChart.setOption({
        legend: {
          bottom: '1px',
          data: legendData
        },
        grid: {
          top: '50px',
          bottom: '150px'
        },
        tooltip: {
          alwaysShowContent: true,
          trigger: 'axis',
          extraCssText: 'z-index: 7',
          backgroundColor: '#FFFFFF',
          textStyle: {
            color: '#3c3520'
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: lineXsData
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '学术论文',
            type: 'line',
            stack: 'Total',
            data: lwSeriesData
          },
          {
            name: '研究报告',
            type: 'line',
            data: bgSeriesData
          },
          {
            name: '图书出版',
            type: 'line',
            data: tsSeriesData
          },
          {
            name: '活动成果',
            type: 'line',
            data: hdSeriesData
          },
          {
            name: '媒体成果',
            type: 'line',
            data: mtSeriesData
          },
          {
            name: '荣誉信息',
            type: 'line',
            data: rySeriesData
          },
          {
            name: '专利成果',
            type: 'line',
            data: zlSeriesData
          },
          {
            name: '软著成果',
            type: 'line',
            data: rzSeriesData
          }
        ]
      }, true)
      setTimeout(function() {
        fruitChart.resize()
      }, 10)
    },
    getRelatedYgData(data) {
      this.getRelatedYgChart(data)
    },
    getRelatedYgChart(fruitData) {
      let fruitChart = echarts.init(this.$refs.groupYgCharts)
      let scholarsData = fruitData.map((item, idx) => {
        return {
          name: item.name,
          itemStyle: {
            normal: {
              color: '#37A095'
            }
          }
        }
      })
      let links = fruitData.map(item => {
        return {
          source: this.selectedAuthorName,
          target: item.name,
          label: {
            show: true,
            fontSize: 12,
            formatter: function(params) {
              return item.deptName
            }
          },
          // name: '合作次数' + item.count,
          itemStyle: {
            normal: {
              color: '#2b579a'
            }
          }
        }
      })
      fruitChart.setOption({
        series: [{
          top: 40,
          type: 'graph', // 类型:关系图
          layout: 'circular', //图的布局，类型为力导图
          height: '70%',
          symbolSize: [50, 30], // 调整节点的大小
          roam: true, // 是否开启鼠标缩放和平移漫游。默认不开启。如果只想要开启缩放或者平移,可以设置成 'scale' 或者 'move'。设置成 true 为都开启
          edgeSymbol: ['circle', 'arrow'],
          edgeSymbolSize: [2, 8],
          edgeLabel: {
            normal: {
              textStyle: {
                fontSize: 20
              },
              show: true,
              formatter: function(x) {
                return x.data.name
              }
            }
          },
          force: {
            repulsion: 2500,
            edgeLength: [10, 50]
          },
          // draggable: true,
          lineStyle: {
            normal: {
              width: 2,
              color: '#4b565b',
              opacity: 0.9,
              curveness: 0.1 // 调整连线的曲度
            }
          },
          label: {
            normal: {
              show: true,
              textStyle: {}
            }
          },

          // 数据
          data: [
            {
              name: this.selectedAuthorName,
              itemStyle: {
                normal: {
                  color: '#2b579a'
                }
              }
            },
            ...scholarsData
          ],
          links: [
            ...links
          ]
        }]
      }, true)

      setTimeout(function() {
        fruitChart.resize()
      }, 10)
    },
    handleTabChange(key) {
      if (key === 'rank' && this.talentRelatedTalentDataList && this.talentRelatedTalentDataList.length > 0) {
        this.$nextTick(() => {
          this.buildRankTalentChart(this.talentRelatedTalentDataList)
        })
      } else if (key === 'related' && this.talentRelatedTalentDataList && this.talentRelatedTalentDataList.length > 0) {
        this.$nextTick(() => {
          this.buildRelatedTalentChart(this.talentRelatedTalentDataList)
        })
      } else if (key === 'rrff' && this.talentRelatedTalentDataList && this.talentRelatedTalentDataList.length > 0) {
        this.$nextTick(() => {
          this.getResearchFieldFruitCharts(this.talentRelatedResearchFieldFruitDataList)
        })
      } else if (key === 'cy' && this.talentFruitWordCloudDataList && this.talentFruitWordCloudDataList.length > 0) {
        this.$nextTick(() => {
          this.getFruitWordCloudData(this.talentFruitWordCloudDataList)
        })
      }
    },
    getRelatedTalentData(data) {
      this.buildRelatedTalentChart(data)
      this.buildRankTalentChart(data)
    },
    buildRelatedTalentChart(fruitData) {
      if (this.$refs.groupTalentCharts) {
        let fruitChart = echarts.init(this.$refs.groupTalentCharts)
        let scholarsData = fruitData.map(item => {
          return {
            name: item.name,
            itemStyle: {
              normal: {
                color: '#37A095'
              }
            }
          }
        })
        let links = fruitData.map(item => {
          return {
            source: this.selectedAuthorName,
            target: item.name,
            label: {
              show: false
            },
            name: '合作论文数' + item.count,
            itemStyle: {
              normal: {
                color: '#2b579a'
              }
            }
          }
        })
        fruitChart.setOption({
          tooltip: {
            formatter: function(x) {
              return x.data.des
            }
          },
          series: [{
            top: 10,
            type: 'graph', // 类型:关系图
            layout: 'circular', //图的布局，类型为力导图
            height: '70%',
            symbol: 'roundRect',
            symbolSize: [50, 30], // 调整节点的大小
            roam: true, // 是否开启鼠标缩放和平移漫游。默认不开启。如果只想要开启缩放或者平移,可以设置成 'scale' 或者 'move'。设置成 true 为都开启
            // edgeSymbol: ['circle', 'arrow'],
            edgeSymbolSize: [2, 8],
            edgeLabel: {
              normal: {
                textStyle: {
                  fontSize: 20
                },
                show: true,
                formatter: function(x) {
                  return x.data.name
                }
              }
            },
            force: {
              repulsion: 2500,
              edgeLength: [10, 50]
            },
            // draggable: true,
            lineStyle: {
              normal: {
                width: 2,
                color: '#4b565b',
                opacity: 0.9,
                curveness: 0.1 // 调整连线的曲度
              }
            },
            label: { // 节点标签单独配置
              show: true,
              width: 50, // 限定文本宽度为 60px
              overflow: 'truncate', // 截断
              ellipsis: '...', // 显示省略号
              textStyle: {}
            },
            // 数据
            data: [
              {
                name: this.selectedAuthorName,
                itemStyle: {
                  normal: {
                    color: '#2b579a'
                  }
                }
              },
              ...scholarsData
            ],
            links: [
              ...links
            ]
          }]
        }, true)
        setTimeout(function() {
          fruitChart.resize()
        }, 10)
      }
    },
    buildRankTalentChart(fruitData) {
      const chartDom = this.$refs.groupRankCharts
      if (!chartDom) return

      const fruitChart = echarts.getInstanceByDom(chartDom) || echarts.init(chartDom)

      // let fruitChart = echarts.init(this.$refs.groupRankCharts);
      let xAxisData = fruitData.map(item => {
        return item.name
      })
      let seriesData = fruitData.map(item => {
        return item.count
      })
      fruitChart.setOption({
        grid: {
          top: 10,
          bottom: 120
        },
        xAxis: {
          type: 'category',
          data: xAxisData,
          axisLabel: {
            inside: false,
            color: '#000',
            interval: 0,
            formatter: function(value) {
              return value.split('').join('\n')
            }
          },
          axisTick: {
            show: false
          },
          axisLine: {
            show: false
          },
          z: 10
        },
        dataZoom: [
          {
            type: 'inside'
          }
        ],
        yAxis: {
          type: 'value',
          minInterval: 1
        },
        tooltip: {
          alwaysShowContent: true,
          trigger: 'axis',
          extraCssText: 'z-index: 7',
          backgroundColor: '#FFFFFF',
          textStyle: {
            color: '#3c3520'
          }
        },
        series: [
          {
            data: seriesData,
            type: 'bar',
            showBackground: true,
            itemStyle: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                { offset: 0, color: '#79DBBA' },
                { offset: 0.5, color: '#3FA598' },
                { offset: 1, color: '#008080' }
              ])
            },
            emphasis: {
              itemStyle: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  { offset: 0, color: '#79DBBA' },
                  { offset: 0.5, color: '#3FA598' },
                  { offset: 1, color: '#008080' }
                ])
              }
            }
          }
        ]
      }, true)

      setTimeout(function() {
        fruitChart.resize()
      }, 10)
    },
    getRecommendTalent(fieldNames) {
      let url = '/fruit/getRecommendTalent'

      let obj = { orgUserId: this.selectedAuthorId, fieldNames: fieldNames }
      postAction(url, obj).then(res => {
        if (res.data.success) {
          // this.buildRelatedTalentChart(res.data.result.result);
          // this.buildRankTalentChart(res.data.result.result);
          this.talentRecommendData = res.data.result.result
        }
      }).catch(err => {
      })
    },
    showFruitInfo(item) {
      this.$nextTick(() => {
        this.$refs.fruitInfo.showModalInfo(item)
      })
    },

    handleFileRemove(file) {
      const index = this.talentFileList.indexOf(file)
      const newFileList = this.talentFileList.slice()
      newFileList.splice(index, 1)
      this.talentFileList = newFileList
    },
    fileBeforeUpload(file) {
      let imgTypeArr = ['pdf', 'docx', 'doc', 'xlsx', 'xls', 'ppt', 'pptx', 'jpg', 'jpeg', 'png', 'zip', 'rar']
      let imgType = imgTypeArr.indexOf(file.name.substring(file.name.lastIndexOf('.') + 1)) !== -1
      if (!imgType) {
        this.$message.warning({
          content: '文件格式不正确, 请选择pdf、docx、doc、xlsx、xls、ppt、pptx、jpg、jpeg、png、zip、rar格式的文件',
          duration: 5
        })
        return false
      }
      // 判断文件大小
      const isLt2M = file.size / 1024 < Setting.uploadFileMaxSize
      if (!isLt2M) {
        this.$message.error('上传附件大小不能超过 20MB!')
        return false
      }
      return true
    },
    uploadSuccess(info) {
      this.talentFileList = info.fileList
      if (info.file.status === 'done') {
        this.$message.success(`${info.file.name} 文件上传成功`)
        this.getTalentFileData()
        this.getTalentFileNum()
      } else if (info.file.status === 'error') {
        this.$message.error(`${info.file.name} file upload failed.`)
      }
    },
    toShareResources() {
      this.uploadModal = true
      if (Setting.isMock) {
        window.localStorage.setItem('sysUserId', '1229')
        window.localStorage.setItem('realname', '李正正')
      }
      let uploadUserId = window.localStorage.getItem('sysUserId')
      let uploadUserName = window.localStorage.getItem('realname')
      this.uploadData = {
        relationId: this.selectedAuthorId,
        uploadUserId: uploadUserId,
        uploadUserName: uploadUserName
      }
      this.getTalentFileData()
    },
    getTalentFileData() {
      let url = '/file/list'
      this.searchTalentFileObj.relationId = this.selectedAuthorId
      this.searchTalentFileObj.pageNo = 1
      this.isHaveFileData = true
      commonPostAction(url, this.searchTalentFileObj).then(res => {
        if (res.data.success) {
          this.talentFileData.total = parseInt(res.data.result.total)
          this.talentFileData.dataList = res.data.result.records
          this.isHaveFileData = false
        }
      }).catch(err => {
      })
    },
    onChangeTalentFilePage(value) {
      this.searchTalentFileObj.pageNo = value
      this.currentFilePage = value
      this.getTalentFileData()
    },
    deleteFile(record) {
      try {
        let url = '/file/delete'
        let that = this
        commonPostAction(url, record).then(res => {
          if (res.data.success) {
            that.$message.success('操作成功')
            that.getTalentFileData()
            this.getTalentFileNum()
          }
        }).catch(err => {
          console.log(err)
        })
      } catch (error) {
        console.error('Error deleting record:', error)
      }
    },
    downloadFileData(record) {
      downloadData('/file/downloadFileData', record, record.name)
    },
    getLikeData() {
      const defaultLikeData = [
        { likeItem: '专业与合作素养', sortIndex: 1, likeCount: 0 },
        { likeItem: '研究成果与贡献', sortIndex: 2, likeCount: 0 },
        { likeItem: '项目参与度', sortIndex: 3, likeCount: 0 },
        { likeItem: '协作效果', sortIndex: 4, likeCount: 0 },
        { likeItem: '协作潜力', sortIndex: 5, likeCount: 0 }
      ]
      this.searchTalentLikeObj = {}
      if (Setting.isMock) {
        window.localStorage.setItem('sysUserId', '1229')
        window.localStorage.setItem('realname', '李正正')
      }
      let userId = window.localStorage.getItem('sysUserId')

      let url = '/evaluate/list'
      this.searchTalentLikeObj.talentId = this.selectedAuthorId
      this.searchTalentLikeObj.userId = userId
      commonPostAction(url, this.searchTalentLikeObj).then(res => {
        if (!res.data.success) return

        const { result } = res.data
        if (Array.isArray(result) && result.length > 0) {
          this.likeData = result.filter(item => item.likeItem !== '点赞')

          if (this.likeData.length === 0) {
            this.likeData = [...defaultLikeData]
          }
          this.likeObj = result.find(item => item.likeItem === '点赞') || null
          this.likeStatus = this.likeObj.likeCount === 1
        } else {
          this.likeData = [...defaultLikeData]
          this.likeObj = {
            talentId: this.searchTalentLikeObj.talentId,
            userId: this.searchTalentLikeObj.userId,
            likeItem: '点赞',
            likeCount: this.likeStatus ? 1 : 0
          }
        }
      }).catch(err => {
      })
    },
    changeLike() {
      this.likeStatus = !this.likeStatus
      let url = '/evaluate/saveSingle'
      if (this.likeObj) {
        this.likeObj.likeCount = this.likeStatus ? 1 : 0
      } else {
        this.likeObj = {
          talentId: this.searchTalentLikeObj.talentId,
          userId: this.searchTalentLikeObj.userId,
          likeItem: '点赞',
          likeCount: this.likeStatus ? 1 : 0
        }
      }
      commonPostAction(url, this.likeObj).then(res => {
        this.getLikeData()
      }).catch(err => {
      })
    },
    changeEvaluate(index, value) {
      this.likeData[index].likeCount = value
      this.likeData.map(item => {
        item.talentId = this.searchTalentLikeObj.talentId
        item.userId = this.searchTalentLikeObj.userId
        return item
      })

      let url = '/evaluate/save'
      this.searchTalentLikeObj.evaluateList = JSON.parse(JSON.stringify(this.likeData))
      commonPostAction(url, this.searchTalentLikeObj).then(res => {
      }).catch(err => {
      })
    },
    showDataAnalysis() {
      this.dataAnalysisModel = true
      this.dataAnalysisList = []

      let url = '/talents/dataAnalysis'
      let searchDaObj = { 'talentId': this.selectedAuthorId }
      postAction(url, searchDaObj).then(res => {
        this.dataAnalysisObj = res.data.result
        this.dataAnalysisObj.field = this.talentInfo.talentFields
        this.dataAnalysisObj.successRate = this.dataAnalysisObj.totalNum > 1 ? '100%' : '0%'
        this.dataAnalysisList.push(res.data.result)
      }).catch(err => {
      })
    },
    showAbilityAnalysis() {
      this.abilityAnalysisModel = true
      this.getAbilityAnalysisData();
    },
    getAbilityAnalysisData() {
      let url = '/talents/getAbilityAnalysisData'
      postAction(url, { authorId: this.selectedAuthorId, pubStartDate: this.yearRange[0], pubEndDate: this.yearRange[1] }).then(res => {
        if (res.data.success) {
          this.abilityAnalysisList = res.data.result;
        }
      })
    },
  }
}
</script>
<style scoped>

::-webkit-scrollbar {
  height: 8px;
  width: 5px;
}

::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background-color: #D8D8D8;
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgb(121, 171, 177);
}

::-webkit-scrollbar-track {
  background-color: transparent;
  padding: 2px;
}

/deep/ .ant-card-body {
  padding: 20px !important;
}

/deep/ .ant-card-head {
  min-height: 20px !important;
}

/deep/ .ant-card-head-title {
  padding: 5px 0 !important;
}

/deep/ .ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab-active {
  background: #1DA57A !important;
  color: #fff !important;
}

.divTitle {
  margin-bottom: -1px;
  background: transparent;
  zoom: 1;
  font-size: 1.2rem;
  font-weight: bold;
  color: #189583;
  padding: 5px 24px;
}

.blank-content {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 300px;
}

.ft {
  font-weight: bold;
  font-size: 20px;
  cursor: pointer;
}

.pag {
  text-align: center;
}


#components-back-top-demo-custom .ant-back-top {
  bottom: 100px;
  right: 20px;
}

#components-back-top-demo-custom .ant-back-top-inner {
  height: 40px;
  width: 40px;
  line-height: 40px;
  border-radius: 4px;
  background-color: rgba(0, 128, 128, 1);
  color: #fff;
  text-align: center;
  font-size: 20px;
}

.t-title {
  font-size: 1.5rem;
  font-weight: bold;
  line-height: 50px;
}

.t-company {
  font-size: 0.9rem;
  font-weight: bold;
  padding-top: 10px;
}

.timeline-keyword {
  display: inline-block;
  margin: 4px 8px 4px 0;
  padding: 10px;
  border-radius: 20px;
  background-color: #eff6ff;
  font-size: 13px;
}
</style>